package com.fengdi.solutions.esay;

import com.fengdi.publicObject.ListNode;

import java.util.Stack;

public class _234_A_linked_palindromic_list {
    public boolean isPalindrome(ListNode head) {
        Stack<Integer> stack = new Stack<Integer>();
        ListNode node = head;
        while(node != null){
            stack.push(node.val);
            node = node.next;
        }

        node = head;

        while (!stack.isEmpty()){
            if(stack.pop() == node.val) {
                node = node.next;
                continue;
            }
            return false;
        }

        return true;
    }
}
